package utils

import (
	"github.com/gin-gonic/gin"
)

type CB func(c *gin.Context) (resp Response)

func API(cb CB) gin.HandlerFunc {

	return func(c *gin.Context) {
		resp := cb(c)
		c.JSON(200, gin.H{
			"code": resp.Code,
			"msg":  resp.Message,
			"data": resp.Data,
		})
	}
}
